package interpreter;
import java.math.BigDecimal;
import java.math.MathContext;


public class DivideBinExpr extends BinExpr{
	
	private DivideBinExpr(Expr l, Expr r){
		super(l,r);
	}
	
	public static Expr _(Expr l, Expr r){
		return new DivideBinExpr(l, r);
	}

	@Override
	public BigDecimal evaluate(Env env) throws Exception{
		BigDecimal bd = null;
		try{
			bd = l.evaluate(env).divide(r.evaluate(env));
		} catch (ArithmeticException e){
			throw new Exception("Division by zero!");
		}
		return bd;
	}
	
}
